package com.example.webview;

import com.example.webview.R;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class PopUp extends Activity {
	
	private Animation animShow, animHide;
	private TransparentPanel popup; 
	private Button showButton;
	private Button hideButton;
	private TextView locationName;
    private TextView locationDescription;
    private Context context;
 
    
    //public PopUp(Context context) {
    //	System.out.println("Contrutor");
    //    this.context = context;
    //     
    //}
 
    public void showToast(String text) {
    	System.out.println("fdsgfdgfdgfdg");
        showPopUp();
    }
    
    
	public Animation getAnimShow() {
		return animShow;
	}

	public void setAnimShow(Animation animShow) {
		this.animShow = animShow;
	}

	public Animation getAnimHide() {
		return animHide;
	}

	public void setAnimHide(Animation animHide) {
		this.animHide = animHide;
	}

	public TransparentPanel getPopup() {
		return popup;
	}

	public void setPopup(TransparentPanel popup) {
		this.popup = popup;
	}

	public Button getShowButton() {
		return showButton;
	}

	public void setShowButton(Button showButton) {
		this.showButton = showButton;
	}

	public Button getHideButton() {
		return hideButton;
	}

	public void setHideButton(Button hideButton) {
		this.hideButton = hideButton;
	}

	public TextView getLocationName() {
		return locationName;
	}

	public void setLocationName( String name ) {
		locationName.setText("Chinatown");
	}

	public TextView getLocationDescription() {
		return locationDescription;
	}

	public void setLocationDescription(String description ) {
		locationDescription.setText(description);
	}

	@Override
	public void onCreate(Bundle icicle) {

        super.onCreate(icicle);
        
        System.out.println("OnCreate");
        
        setContentView(R.layout.activity_pop_up);
     
        initPopup();
    }
	
	public void initPopup() {
    	
    	popup = (TransparentPanel) findViewById(R.id.popup_window );

    	//  Start out with the popup initially hidden.
    	popup.setVisibility(View.GONE);
    	
    	
    	animShow = AnimationUtils.loadAnimation( this, R.anim.popup_show  );
    	animHide = AnimationUtils.loadAnimation( this, R.anim.popup_hide );
    	
    	showButton = (Button) findViewById(R.id.show_popup_button );
    	hideButton = (Button) findViewById(R.id.hide_popup_button );
    	
    	showButton.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				showPopUp();
        }});
        
        hideButton.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				hidePopUp();
        }});


    	locationName = (TextView) findViewById(R.id.location_name );
        locationDescription = (TextView) findViewById(R.id.location_description);
        
        setLocationName("Chinatown");
        setLocationDescription("Chinatown has always been one of the first places tourists go in San Francisco."
        							+ "  Not only can you find great chinese food and trinket shopping, but learn"
        							+ " about the history of the city and the Chinese culture that is such a strong"
        							+ " part if it");
	}	
	
	public void showPopUp(){
		popup.setVisibility(View.VISIBLE);
		popup.startAnimation( animShow );
		showButton.setEnabled(false);
		hideButton.setEnabled(true);
	}
	
	public void hidePopUp()
	{
		popup.startAnimation( animHide );
		showButton.setEnabled(true);
		hideButton.setEnabled(false);
		popup.setVisibility(View.GONE);
	}
}

